﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Simulation
{
	class C_SINK
	{
		F_SETT	ST = new F_SETT();

		int		RNID;
		Random	R;

		public int RandEvent()
		{
			R = new Random( unchecked( ( int )DateTime.Now.Ticks ) );

			RNID = R.Next( 1, ST.OTTND );
			return RNID;
		}

		public bool ChooseSinkhole( int R )
		{
			if ( R <= ST.OSINK )
				return true;

			return false;
		}

		public void MakeSinkholeNode( C_NODE[] ND )
		{
			int ndid = -1;

			if ( ST.OSINK == 1 )
			{
				// F_SETT TB_SKHC.Text가 0이면, Randon Sinkhole 발생
				if ( ST.OSKHC == 0 )
					ndid = RandEvent();
				
				for ( int i = 1; i < ST.OTTND; i++ )
				{
				    if ( ( ND[i].HPCT == ST.OSKHC ) && ( ND[i].SKND == false ) )
						ndid = i;
				}

				ND[ndid].SKND = true;				
			}
		}
	}
}
